package org.lanyu.springainovel.chat.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.lanyu.springainovel.chat.service.ChatMemoryService;
import org.lanyu.springainovel.common.vo.RestVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "AI对话记录", description = "AI对话记录（对话气泡）")
@RestController
@RequestMapping("/memory")
public class MemoryController {
    @Autowired
    private ChatMemoryService chatMemoryService;

    public MemoryController() {
        super();
    }

    @Operation(summary = "清除会话上下文", description = "根据 sessionId 清除该会话的所有消息记录")
    @PostMapping("/clearSession")
    public RestVO<String> clearSession(@RequestParam String sessionId) {
        chatMemoryService.clearSessionHistory(sessionId);
        return RestVO.success("已清除会话上下文");
    }
}
